# n-snakes: Multidimentional, procedural exploration game.
# http://code.google.com/p/n-snakes/
#
#
# Copyright (c) 2012 Eliot Eshelman
#
# Built upon Snakes demo written by Jessica McKellar for OpenHatch
# https://openhatch.org/wiki/Snakes_Pygame
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###############################################################################

import pygame
import random

class Food(pygame.sprite.Sprite):
    """
    A piece of snake food.

    Members:
        image  - visible pygame Surface
        rect   - the dimensions of the food
        color  - the color of the food
    """

    FOOD_UNIT = 15
    FOOD_COLORS = (
            pygame.Color(0xff, 0x66, 0x00),
            pygame.Color(0xfc, 0xff, 0x00),
            pygame.Color(0x00, 0x7e, 0xff),
            pygame.Color(0xa2, 0x00, 0xff),
            pygame.Color(0xff, 0xff, 0xff)
        )

    def __init__(self, game_rect):
        # Initialize parent Sprite class
        pygame.sprite.Sprite.__init__(self)

        self.image = pygame.Surface((self.FOOD_UNIT, self.FOOD_UNIT))

        # Give the food piece a random color.
        self.color = random.choice(self.FOOD_COLORS)
        self.image.fill(self.color)

        # Place the food piece randomly on the screen.
        self.rect = self.image.get_rect()
        self.rect.topleft = [
            random.randint(0, game_rect.width - self.FOOD_UNIT),
            random.randint(0, game_rect.height - self.FOOD_UNIT)
        ]
